package com.zxmc.server.controller.user;

import com.zxmc.common.result.Result;
import com.zxmc.pojo.dto.AddFriendDto;
import com.zxmc.pojo.dto.DeleteFriendDto;
import com.zxmc.pojo.entity.Friend;
import com.zxmc.server.service.FriendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/friend")
@Slf4j
@Api(tags = "好友相关接口")
public class FriendController {

    @Autowired
    private FriendService friendService;

    @GetMapping("/list")
    @ApiOperation("查询好友列表")
    public Result<List<Friend>> list(String name){
        log.info("查询好友列表");
        return Result.success(friendService.list(name));
    }
    @PostMapping("/add")
    @ApiOperation("添加好友")
    public Result add(@RequestBody AddFriendDto addFriendDto){
        log.info("添加好友");
        friendService.add(addFriendDto);
        return Result.success();
    }
    @DeleteMapping("/delete")
    @ApiOperation("删除好友")
    public Result delete(@RequestBody DeleteFriendDto deleteFriendDto){
        log.info("删除好友");
        friendService.delete(deleteFriendDto);
        return Result.success();
    }
}
